package com.yztc.love_travel.http;

import com.yztc.love_travel.bean.HistoryBean;
import com.yztc.love_travel.bean.PlayinLocalBean;
import com.yztc.love_travel.bean.SceneryStrategyBean;
import com.yztc.love_travel.bean.fourtrip.FourTripBean;
import com.yztc.love_travel.bean.fourtrip.FourTripDetailsBean;
import com.yztc.love_travel.bean.homepage.RecommendTripNotesBean;
import com.yztc.love_travel.retrofitinterface.RetrofitInterface;

import java.util.Map;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.Observable;

/**
 * Created by 周旭 on 2016/11/28.
 */

public class HttpUtils {

    private static Retrofit retrofit;
    private static RetrofitInterface retrofitInterface;

    private static void initRetrofit(String baseUrl){
        retrofit = new Retrofit.Builder()
                .baseUrl(baseUrl)
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();
        retrofitInterface =  retrofit.create(RetrofitInterface.class);
    }

    //获取"四大推荐旅行"的列表的数据
    public static Observable<FourTripBean> getFourTripBean(String baseUrl, Map<String,Object> params){
        initRetrofit(baseUrl);
      return retrofitInterface.gerFourTripBean(params);
    }

    //获取"推荐游记"列表的数据
    public static Observable<RecommendTripNotesBean> getRecommendTripNotesBean(String baseUrl,Map<String,Object> params){
        initRetrofit(baseUrl);
        return retrofitInterface.getRecommendTripNotesBean(params);
    }
    //获取"历史"列表的数据
    public static Observable<HistoryBean> getHistoryCultureBean(String baseUrl, Map<String,Object> params){
        initRetrofit(baseUrl);
        return retrofitInterface.getHistoryCultureBean(params);
    }

    //获取"景点攻略"列表的数据
    public static Observable<SceneryStrategyBean> getSceneryStrategyBean(String baseUrl, Map<String,Object> params){
        initRetrofit(baseUrl);
        return retrofitInterface.getSceneryStrategyBean(params);
    }
    //获取"玩当地"列表的数据
    public static Observable<PlayinLocalBean> getPlayinLocalBean(String baseUrl, Map<String,Object> params){
        initRetrofit(baseUrl);
        return retrofitInterface.getPlayinLocalBean(params);
    }
    //获取"四大推荐旅行"的列表的Item的详情数据
    public static Observable<FourTripDetailsBean> getFourTripDetailsBean(String baseUrl,int destinationId){
     initRetrofit(baseUrl);
        return retrofitInterface.getFourTripDetails(destinationId);
    }

}
